﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

/// <summary>
/// 玩家的输入控制器.
/// </summary>
public class InputController : MonoBehaviour
{
    private void Awake()
    {
        InitWidget();
        //TODO:增加按钮.
    }

    private PlayerCharacter _player;

    private void InitWidget()
    {
        _player = FindObjectOfType<PlayerCharacter>();
    }

    private void Update()
    {
        if (!GameManager.Instance.IsGaming || !_player.IsAlive)
        {
            return;
        }
        if (Input.GetKeyUp(KeyCode.Q) || Input.GetButtonDown("LB"))
        {
            CameraView.Instance.ChangeView(-1);
        }
        if (Input.GetKeyUp(KeyCode.E) || Input.GetButtonDown("RB"))
        {
            CameraView.Instance.ChangeView(1);
        }
        if (Input.GetKeyDown(KeyCode.Space) || Input.GetButtonDown("A"))
        {
            _player.Jump();
        }

        //移动控制.
        var h = Input.GetAxis("Horizontal");
        _player.Move(h);
    }
}
